﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ShortcutToolbox.Core;

namespace ShortcutToolbox.View
{
    public partial class ConfigurationForm : Form, ILangConnector
    {
        static ConfigurationForm _instance = null;
        static object _locker = new object();

        public static ConfigurationForm Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (_locker)
                    {
                        if (_instance == null)
                            _instance = new ConfigurationForm();
                    }
                }
                return _instance;
            }
        }

        public ConfigurationForm()
        {
            InitializeComponent();
            I18N.Changed += OnLangeChanged;
            OnLangeChanged(this, new LanguageChangedEventArgs(I18N.Current));
        }

        public void OnLangeChanged(object sender, LanguageChangedEventArgs e)
        {
            dynamic dylang = e.Value;
            Text = dylang.ConfigurationForm.Title;
        }

        protected override void OnClosed(EventArgs e)
        {
            I18N.Changed -= OnLangeChanged;
            base.OnClosed(e);
            _instance = null;
        }

        private void ConfigurationForm_Load(object sender, EventArgs e)
        {

        }
    }
}
